package star.crust.cartspace.framework;

import java.util.ArrayList;
import java.util.Iterator;

public class CrtMesh {
	public String id = "";
	protected ArrayList<CrtMeshPrimitive> meshePrimitives = new ArrayList<CrtMeshPrimitive>();
	
	public CrtMesh() {
		
	}
	
	public void addMeshPrimitive(CrtMeshPrimitive tm) {
		meshePrimitives.add(tm);
	}
	
	public Iterator<CrtMeshPrimitive> iterator() {
		return meshePrimitives.iterator();
	}
	
	public int size() {
		return meshePrimitives.size();
	}
	
	public String toString() {
		String doc = "";
		doc += super.toString() + "\n";
		Iterator<CrtMeshPrimitive> iterator = meshePrimitives.iterator();
		while(iterator.hasNext()) doc += iterator.next().toString() + "\n";
		return doc;
	}

	// Per Solid/Rapid
	private String type;

	public CrtMesh(String type) {
		this.type=type;
		this.meshePrimitives = new ArrayList<CrtMeshPrimitive>();
	}
	public void clearMesh()
	{
		this.meshePrimitives.clear();
	}
	public ArrayList<CrtMeshPrimitive> getPolygon()
	{
		return this.meshePrimitives;
	}
	public String getType()
	{
		return this.type;
	}
	public void setPartArray(int index, ArrayList<CrtMeshPrimitive> list)
	{
		this.meshePrimitives.addAll(index, list);
	}

}
